-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix cctp submitter race #2853
fix cctp submitter race #2853
Conversation
WalkthroughThe recent changes enhance error handling in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Addressed race condition in transaction submitter
- Added check to ensure submitter starts only once
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2853 +/- ##
===================================================
+ Coverage 25.65579% 25.65620% +0.00040%
===================================================
Files 768 768
Lines 55239 55242 +3
Branches 80 80
===================================================
+ Hits 14172 14173 +1
- Misses 39594 39596 +2
Partials 1473 1473
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Deploying sanguine-fe with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added check to ensure transaction submitter starts only once in
/services/rfq/relayer/service/relayer.go
- Improved error handling for transaction submission
- Enhanced reliability of transaction submission by preventing redundant start attempts
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- services/cctp-relayer/relayer/relayer.go (2 hunks)
Additional comments not posted (3)
services/cctp-relayer/relayer/relayer.go (3)
308-308
: Check if the transaction submitter is already started.This line adds a condition to check if the transaction submitter is already started before attempting to start it. This is a good practice to avoid redundant operations.
309-312
: Handle errors gracefully when starting the transaction submitter.These lines handle errors more gracefully by only returning an error if the submitter fails to start and the error is not due to the submitter already being in a started state. This prevents the method from failing due to an already started submitter.
314-314
: Ensure consistent return of nil in the goroutine.This line ensures that the goroutine returns nil if the transaction submitter is already started or successfully started. This maintains consistency in the error handling and return values of the goroutines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
if !c.txSubmitter.Started() { | ||
err := c.txSubmitter.Start(ctx) | ||
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | ||
return fmt.Errorf("could not start tx submitter: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error Handling Improvement: Check if txSubmitter has already started.
The added check ensures that the transaction submitter is not started multiple times, preventing redundant operations and potential errors. However, the conditional block can be simplified for better readability.
- if !c.txSubmitter.Started() {
- err := c.txSubmitter.Start(ctx)
- if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) {
- return fmt.Errorf("could not start tx submitter: %w", err)
- }
- }
+ if c.txSubmitter.Started() {
+ return nil
+ }
+ err := c.txSubmitter.Start(ctx)
+ if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) {
+ return fmt.Errorf("could not start tx submitter: %w", err)
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if !c.txSubmitter.Started() { | |
err := c.txSubmitter.Start(ctx) | |
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | |
return fmt.Errorf("could not start tx submitter: %w", err) | |
} | |
if c.txSubmitter.Started() { | |
return nil | |
} | |
err := c.txSubmitter.Start(ctx) | |
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | |
return fmt.Errorf("could not start tx submitter: %w", err) | |
} |
if !r.submitter.Started() { | ||
err := r.submitter.Start(ctx) | ||
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | ||
return fmt.Errorf("could not start submitter: %w", err) | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error Handling Improvement: Check if submitter has already started.
The added check ensures that the transaction submitter is not started multiple times, preventing redundant operations and potential errors. However, the conditional block can be simplified for better readability.
- if !r.submitter.Started() {
- err := r.submitter.Start(ctx)
- if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) {
- return fmt.Errorf("could not start submitter: %w", err)
- }
- return nil
- }
+ if r.submitter.Started() {
+ return nil
+ }
+ err := r.submitter.Start(ctx)
+ if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) {
+ return fmt.Errorf("could not start submitter: %w", err)
+ }
+ return nil
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if !r.submitter.Started() { | |
err := r.submitter.Start(ctx) | |
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | |
return fmt.Errorf("could not start submitter: %w", err) | |
} | |
return nil | |
if r.submitter.Started() { | |
return nil | |
} | |
err := r.submitter.Start(ctx) | |
if err != nil && !errors.Is(err, submitter.ErrSubmitterAlreadyStarted) { | |
return fmt.Errorf("could not start submitter: %w", err) | |
} | |
return nil |
Description
fixes submitter race
Summary by CodeRabbit